package com.ty.day7;

import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * Author : txy
 * Create 2023/11/3 10:12
 */
public class One {
    public static void main(String[] args) {
        int n = 6;
        int[][] a = new int[n][n];
        for (int[] ints : a) {
            Arrays.fill(ints, 1);
        }
        for (int i = 2; i < a.length; i++) {
            for (int j = 1; j < i; j++) {
                a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
            }
        }
        for (int i = 0; i < a.length; i++) {
            for (int j = i; j < a.length - 1; j++) {
                System.out.print(" ");
            }
            for (int j = 0; j <= i; j++) {
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println();

        int[] b = new int[n];
        int[] c = new int[b.length];
        Arrays.fill(b, 1);
        Arrays.fill(c, 1);
        for (int i = 0; i < b.length; i++) {
            if (i > 1) {
                for (int j = 1; j < i; j++) {
                    b[j] = c[j] + c[j - 1];
                }
            }
            for (int j = i; j < a.length - 1; j++) {
                System.out.print(" ");
            }
            for (int j = 0; j <= i; j++) {
                System.out.format("%-3d", b[j]);
                c[j] = b[j];
            }
            System.out.println();
        }

    }
}
